package com.dews.system.service.impl;

import java.util.List;

import com.dews.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dews.system.mapper.SysUserTestMapper;
import com.dews.system.domain.SysUserTest;
import com.dews.common.bean.user.SysUserTestBean;
import com.dews.system.convert.SysUserTestConvert;
import com.dews.system.service.ISysUserTestService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dews.common.utils.bean.BeanUtils;

/**
 * 测试业务Service业务层处理
 *
 * @author rakic
 * @date 2024-01-22
 */
@Service
public class SysUserTestServiceImpl extends ServiceImpl<SysUserTestMapper, SysUserTest> implements ISysUserTestService {
    @Autowired
    private SysUserTestMapper sysUserTestMapper;

    /**
     * 查询测试业务
     *
     * @param testId 测试业务主键
     * @return 测试业务
     */
    @Override
    public SysUserTestBean selectSysUserTestByTestId(Long testId) {
        BeanUtils.checkIdsEmpty(testId);
        return sysUserTestMapper.selectSysUserTestByTestId(testId);
    }

    /**
     * 查询测试业务列表
     *
     * @param sysUserTest 测试业务
     * @return 测试业务
     */
    @Override
    public List<SysUserTestBean> selectSysUserTestList(SysUserTestBean sysUserTestBean) {
        return sysUserTestMapper.selectSysUserTestList(sysUserTestBean);
    }

    /**
     * 新增测试业务
     *
     * @param sysUserTest 测试业务
     * @return 结果
     */
    @Override
    public int insertSysUserTest(SysUserTestBean sysUserTestBean) {
        SysUserTest sysUserTest = SysUserTestConvert.INSTANCE.convert(sysUserTestBean);

        sysUserTest.setCreateTime(DateUtils.getNowDate());

        return sysUserTestMapper.insert(sysUserTest);

    }

    /**
     * 修改测试业务
     *
     * @param sysUserTest 测试业务
     * @return 结果
     */
    @Override
    public int updateSysUserTest(SysUserTestBean sysUserTestBean) {
        //BeanUtils.checkIdsEmpty(testId);

        SysUserTest sysUserTest = SysUserTestConvert.INSTANCE.convert(sysUserTestBean);
        sysUserTest.setUpdateTime(DateUtils.getNowDate());
        return sysUserTestMapper.updateSysUserTest(sysUserTest);
    }

    /**
     * 批量删除测试业务
     *
     * @param testIds 需要删除的测试业务主键
     * @return 结果
     */
    @Override
    public int deleteSysUserTestByTestIds(List<Long> testIds) {
        BeanUtils.checkIdsEmpty(testIds);
        return sysUserTestMapper.deleteBatchIds(testIds);
    }

    /**
     * 删除测试业务信息
     *
     * @param testId 测试业务主键
     * @return 结果
     */
    @Override
    public int deleteSysUserTestByTestId(Long testId) {
        BeanUtils.checkIdsEmpty(testId);
        return sysUserTestMapper.deleteById(testId);
    }

}
